/**
    Copyright (c) 2010-2011 yakiimo02
    Distributed under the New BSD License.
    See included license.txt or http://www.yakiimo3d.com/NewBSDLicense.txt
**/

#pragma once

/**
    @brief  Displays a texture full screen.
    @date   09/11/28
*/
class FullScreenQuad
{
protected:
    struct SCREEN_VERTEX
    {
        D3DXVECTOR4 pos;
        D3DXVECTOR2 tex;
    };

public:
    FullScreenQuad();
    ~FullScreenQuad();

    HRESULT OnCreateDevice( ID3D11Device* pd3dDevice );
    HRESULT OnFrameRender( ID3D11Device* pd3dDevice, ID3D11DeviceContext* pd3dImmediateContext, const DXGI_SURFACE_DESC* pBackBufferDesc, 
                            int nBufWidth, int nBufHeight );
    void    OnDestroyDevice();

    inline void SetpTextureSRV( ID3D11ShaderResourceView* pTextureSRV ) { m_pTextureSRV = pTextureSRV; }

protected:
    void DrawFullScreenQuad( ID3D11DeviceContext* pd3dImmediateContext, ID3D11PixelShader* pPS, UINT Width, UINT Height );

protected:
    // geometry
    ID3D11InputLayout*          m_pQuadLayout;
    ID3D11Buffer*               m_pVB;
    // shader
    ID3D11VertexShader*         m_pQuadVS;
    ID3D11PixelShader*          m_pQuadPS;
    ID3D11SamplerState*         m_pSampleStatePoint;
    ID3D11ShaderResourceView*   m_pTextureSRV;
    ID3D11Buffer*               m_pConstantBuf;                 // Constant buffer for passing parameters
};

extern FullScreenQuad        g_fullScreenQuad;
